import urllib2
from lxml import html

def connectToPage(url):
    opener = urllib2.build_opener()
    opener.addheaders = [('User-agent', 'Mozilla/5.0')]
    while True:
		try:
			infile = opener.open(url) 
			#print "open"
			page = infile.read()
			print "connected to " + url;
			break;
		except:
			print "problem in " + url
			continue;
		
    #We are using lxml to parse the obtained html page and access the required fields in the html page
    
    lxmlObject = html.fromstring(page)
    return lxmlObject;
